<?php
require('config.php');
		$user_id=$_REQUEST['user_id'];
        $money=$_REQUEST['money'];
        $type=$_REQUEST['type'];
        $orderNo=$_REQUEST['orderNo'];
        $time=date('Y-m-d H:i:s');
        $time2=time();
		$sql="select * from `".$oto."_users` where `userId`='".$user_id."'";
		$result=$db->query($sql);
		while($row=$result->fetch_assoc()){
			$user_info[]=$row;//将取得的所有数据赋值给person_info数组
		}
		$sql="select * from `".$oto."_money_record` where `orderNo`='".$orderNo."'";
		$result=$db->query($sql);
		while($row=$result->fetch_assoc()){
			$record[]=$row;//将取得的所有数据赋值给person_info数组
		}
		if(!isset($record))
		{
			$balance=$user_info[0]['userMoney']+$money;
			if($type=='weixin')
			{
				$cz_type='微信充值';
				$pay_way_lin=2;
			} 
			if($type=='alipay')
			{
				$cz_type='支付宝充值';
				$pay_way_lin=1;
			} 
			$hmoney=$user_info[0]['userMoney']+$money;
			$sql="update ".$oto."_users set userMoney='$hmoney' where userId='{$user_id}'";
			$result2=$db->query($sql);
			$sql="INSERT INTO ".$oto."_money_record (`userid`,`orderNo`,`money`,`balance`,`time`,`IncDec`,`type`,`remark`,`payWay`) VALUES ('$user_id','$orderNo','$money','$balance','$time2','1','3','$cz_type','$pay_way_lin')";
            $result=$db->query($sql);
            if($result2)
            {
            	$data[0]['pan']='true';
            }
            else
            {
            	$data[0]['pan']='false';
            }
            echo json_encode($data);
		}
		else echo '[]';
		
?>